

function login() {
    var baseUrl = document.getElementById("baseURL").value;
    var moduleUrl = "/furerp/";
    var message = document.getElementById("message");
    var username = document.getElementById("username").value;
    if("" == username){
        message.innerText = "用户名不能为空";
        return;
    }
    var password = document.getElementById("password").value;
    var senddata = "username=" + username + "&password=" + password;
    var xhr = new XMLHttpRequest();
    xhr.open("POST", baseUrl + moduleUrl + "loginSubmit");
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.onreadystatechange = function () {
        if(4 === xhr.readyState){
            if(200 === xhr.status){
                if(null == xhr.responseText){
                    return;
                }
                var resultJson = eval("(" + xhr.responseText + ")");
                if(null != resultJson && null != resultJson["hrefUrl"]) {
                    // 有跳转链接返回, 跳转页面

                    window.location.href = baseUrl + "/" + resultJson.hrefUrl;
                }
                else {
                    // 没有跳转链接, 显示错误消息
                    message.innerText = resultJson.excep;
                }
            }
        }
    }
    xhr.send(senddata);
}